package com.jianbing.util;

import java.util.Timer;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
/**
 * Created by Han, Tixiang on 2016/8/30 0030.
 */
public class SchedulerHelper {
    private static Timer timer = null;
    private static ScheduledExecutorService scheduledExecutorService = null;

    public static Timer getTimer() {
        if (timer == null) {
            synchronized (SchedulerHelper.class) {
                if (timer == null) {
                    timer = new Timer();
                }
            }
        }
        return timer;
    }
    public static ScheduledExecutorService getScheduledExecutorService() {
        if (scheduledExecutorService == null) {
            synchronized (SchedulerHelper.class) {
                if (scheduledExecutorService == null) {
                    scheduledExecutorService =  Executors.newScheduledThreadPool(5);
                }
            }
        }
        return scheduledExecutorService;
    }
}